home *** CD-ROM | disk | FTP | other *** search
/ Winzipper / Winzipper_ISO.iso / programming / oracle7 7.2 / DB / UTIL72 / EXAMP5.SQL < prev    next >
Encoding:
Text File  |  1995-05-18  |  1.3 KB  |  46 lines

  1. rem 
  2. rem $Header: examp5.sql 7020100.1 94/09/28 16:39:52 cli Generic<base> $ 
  3. rem 
  4. Rem  Copyright (c) 1991 by Oracle Corporation 
  5. Rem    NAME
  6. Rem      examp5.sql - <one-line expansion of the name>
  7. Rem    DESCRIPTION
  8. Rem      <short description of component this file declares/defines>
  9. Rem    RETURNS
  10. Rem 
  11. Rem    NOTES
  12. Rem      <other useful comments, qualifications, etc.>
  13. Rem    MODIFIED   (MM/DD/YY)
  14. Rem     rvasired   05/12/92 -  Creation 
  15. /*
  16. ** This block does some numeric processing on data that
  17. ** comes from experiment #1.  The results are stored in
  18. ** the TEMP table.
  19. **
  20. ** Copyright (c) 1989,1992 Oracle Corporation
  21. */
  22.  
  23. DECLARE
  24.     num1    data_table.n1%TYPE;   -- Declare variables
  25.     num2    data_table.n2%TYPE;   -- to be of same type as
  26.     num3    data_table.n3%TYPE;   -- database columns
  27.     result  temp.num_col1%TYPE;
  28.     CURSOR c1 IS
  29.         SELECT n1, n2, n3 FROM data_table
  30.             WHERE exper_num = 1;
  31. BEGIN
  32.     OPEN c1;
  33.     LOOP
  34.         FETCH c1 INTO num1, num2, num3;
  35.         EXIT WHEN c1%NOTFOUND;
  36.             -- the c1%NOTFOUND condition evaluates
  37.             -- to TRUE when FETCH finds no more rows
  38.         /* calculate and store the results */
  39.         result := num2/(num1 + num3);
  40.         INSERT INTO temp VALUES (result, NULL, NULL);
  41.     END LOOP;
  42.     CLOSE c1;
  43.     COMMIT;
  44. END;
  45. /
  46.